<template>
  <div class="app-container">
    <el-row :gutter="20">
      <!--      &lt;!&ndash;部门数据&ndash;&gt;
            <el-col :span="4" :xs="24">
              <div class="head-container">
                <el-input
                  v-model="deptName"
                  placeholder="请输入部门名称"
                  clearable
                  size="small"
                  prefix-icon="el-icon-search"
                  style="margin-bottom: 20px"
                />
              </div>
              <div class="head-container">
                <el-tree
                  :data="deptOptions"
                  :props="defaultProps"
                  :expand-on-click-node="false"
                  :filter-node-method="filterNode"
                  ref="tree"
                  default-expand-all
                  @node-click="handleNodeClick"
                />
              </div>
            </el-col>-->
      <!--用户数据-->
      <el-col :span="20" :xs="24" style="width: 100%;">
        <el-form :model="queryParams" ref="msgFrom" :inline="true" v-show="true" label-width="68px" prop="msgFrom">
          <el-form-item label="用户名称" prop="name">
            <el-input
              v-model="queryParams.user_name"
              placeholder="请输入用户名称"
              clearable
              size="small"
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="预约电话" prop="name">
            <el-input
              v-model="queryParams.visit_tel"
              placeholder="请输入预约电话"
              clearable
              size="small"
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="状态" prop="type">
            <el-select
              v-model="queryParams.status"
              placeholder="状态"
              clearable
              size="small"
              style="width: 240px"
            >
              <el-option
                v-for="dict in state"
                :key="dict.dict_value"
                :label="dict.dict_label"
                :value="dict.dict_value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="预约时间">
            <el-date-picker
              v-model="dateRange"
              size="small"
              style="width: 240px"
              value-format="yyyy-MM-dd"
              type="daterange"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            ></el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>


        <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="预约编号" align="center" key="id" prop="id"  />
          <el-table-column label="用户编号" align="center" key="user_id" prop="user_id"  />
          <el-table-column label="预约姓名" align="center" key="user_name" prop="user_name"  :show-overflow-tooltip="true" />
          <el-table-column label="活动标题" align="center" key="title" prop="title"  :show-overflow-tooltip="true" />
          <el-table-column label="预约人数" align="center" key="visit_people" prop="visit_people"  :show-overflow-tooltip="true" />
          <el-table-column label="预约手机号" align="center" key="visit_tel" prop="visit_tel"  :show-overflow-tooltip="true" />
          <el-table-column label="预约状态" align="center" :show-overflow-tooltip="true" >
            <template slot-scope="scope">

                <el-link effect="_blank"  v-if="scope.row.status=='WAIT_CHECK'">待审核</el-link>
                <el-link effect="primary"  v-if="scope.row.status=='REFUSE'">评审失败</el-link>
                <el-link effect="_blank"  v-if="scope.row.status=='VISITED'">已体验</el-link>
                <el-link type="success" effect="dark"  v-if="scope.row.status=='PASS'">预约成功</el-link>
                <el-link type="danger" effect="dark"  v-if="scope.row.status=='CANCEL'">取消预约</el-link>
            </template>
          </el-table-column>
          <el-table-column label="预约时间" align="center" prop="visit_date"  width="160">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.visit_date) }}</span>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getActivityOrder"
        />
      </el-col>
    </el-row>

    <!-- 添加或修改参数配置对话框 -->
    <!--<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="用户昵称" prop="name">
              <el-input v-model="form.name" placeholder="请输入用户昵称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            &lt;!&ndash;<el-form-item label="归属部门" prop="deptId">
              <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
            </el-form-item>&ndash;&gt;
            <el-form-item label="用户生日" prop="deptId">
              <el-input v-model="form.birthday" placeholder="请输入用户生日" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="手机号码" prop="user_mobile">
              <el-input v-model="form.user_mobile" placeholder="请输入手机号码" maxlength="11" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="邮箱" prop="email">
              <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item  label="职业" prop="occupation">
              <el-input v-model="form.occupation" placeholder="请输入用户职业" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="用户密码" >
              <el-input v-model="form.user_password" placeholder="请输入用户密码"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="用户性别">
              <el-select v-model="form.sex" placeholder="请选择">
                &lt;!&ndash;<el-option

                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>&ndash;&gt;
                <el-option
                  v-for="item in sexs"
                  :key="item.id"
                  :label="item.label"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="状态">
              <el-radio-group v-model="form.status">
                <el-radio
                  v-for="item in status"
                  :key="item.id"
                  :label="item.id"
                >{{item.label}}</el-radio>

              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="证件类型">
              <el-select v-model="form.id_card_type">
                <el-option
                  v-for="item in id_card_type"
                  :key="item.id"
                  :label="item.label"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="证件编号">
                <el-input v-model="form.id_card" placeholder="请输入证件编号" type="text" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="用户头像">
              <el-upload class="avatar-uploader"
                         :action="''"
                         :auto-upload="false"
              :show-file-list="false"
              :on-change="handleAvatarChangeIcon">
              <img v-if="user.avator" :src="user.avator" class="avatar" style="height: 150px;">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>

            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="备注">
              <el-input v-model="form.remarks" type="textarea" placeholder="请输入内容"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>-->


  </div>
</template>

<script>
  import { getActivityOrder, updateUser, userSubscription, msgType ,userMsg} from "@/api/system/user";
  import { getToken } from "@/utils/auth";

  export default {
    name: "Msg",
    data() {
      return {
        state: [],
        /*消息类型*/
        msgType:[
          {
            id: 'LOGIN',
            label: '登录'
          },
          {
            id: 'BIRTHDAY',
            label: '生日'
          },
          {
            id: 'MARK',
            label: '用户积分'
          },
          {
            id: 'USER_LEVEL',
            label: '用户等级'
          },
        ],
        /*表格数据*/
        list:[],
        // 总条数
        total: 0,
        // 日期范围
        dateRange: [],
        // 用户导入参数
        upload: {
          // 是否显示弹出层（用户导入）
          open: false,
          // 弹出层标题（用户导入）
          title: "",
          // 遮罩层
          loading: true,
          // 是否禁用上传
          isUploading: false,
          // 是否更新已经存在的用户数据
          updateSupport: 0,
          // 设置上传的请求头部
          headers: { Authorization: "Bearer " + getToken() },
        },
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          name: "",
          subscription:undefined,
          type:undefined,
          read_flag:undefined
        },
      };
    },
    watch: {

    },
    created() {
      this.getActivityOrder();
      this.getDicts("sys_activityOrder_state").then(response => {
        this.state = response.data.items;
        console.log(this.flag)
      });
    },

    methods: {

      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.page = 1;
        this.getActivityOrder();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.dateRange = [];
        this.resetForm('msgFrom');
        this.handleQuery();
      },


      /*获取用户消息列表*/
      getActivityOrder(){
        this.loading = true;
        getActivityOrder(this.addDateRange(this.queryParams, this.dateRange)).then(response=>{
          this.list= response.data.items;
          this.total = response.data.total;
          this.loading = false;
        })
      },

      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.user_id);
        this.single = selection.length != 1;
        this.multiple = !selection.length;
      },
    },

  };
</script>
